package cn.tedu.ivos.vehicleRepair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.vehicleRepair.pojo.dto.VehicleRepairParam;
import cn.tedu.ivos.vehicleRepair.pojo.dto.VehicleRepairquery;
import cn.tedu.ivos.vehicleRepair.pojo.vo.VehicleRepairVO;
import cn.tedu.ivos.vehicleRepair.service.VehicleRepairService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/repair")
public class VehicleRepairController {

    @Autowired
    private VehicleRepairService vehicleRepairService;

    @SneakyThrows
    @PostMapping("/save")
    public JsonResult saveVehicleRepair(VehicleRepairParam vehicleRepairParam)  {
        log.debug("保存维修车辆参数:vehicleParam:{} ", vehicleRepairParam);
        vehicleRepairService.saveVehicleRepair(vehicleRepairParam);
        return JsonResult.ok();
    }

    @GetMapping("/select")
    public JsonResult selectVehicleRepair(VehicleRepairquery vehicleQuery){
        log.debug("查询维修车辆参数: vehicleQuery = {}",vehicleQuery);
        List<VehicleRepairVO> list = vehicleRepairService.selectVehicleRepair(vehicleQuery);
        log.debug("查询车辆信息参数: {}",list);
        return JsonResult.ok(list);
    }

    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        log.debug("删除维修车辆数据参数 id:{}",id);
        vehicleRepairService.delete(id);
        return JsonResult.ok();
    }
}
